package unit9_10;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/*
* 查：
* */

public class testDemo2 {
    public static void main(String[] args) {
        Connection connect = null;
        Statement statement = null;
//        获取对象数据库连接
        connect = JDBC_test2.getConn();
//        编写SQL语句
        String sql="select * from person;";

        try {
//            用statement对象来执行SQL
            statement=connect.createStatement();
            ResultSet resultSet=statement.executeQuery(sql);
            while(resultSet.next()){
                Integer id= resultSet.getInt("id");
                Integer age= resultSet.getInt("age");
                String name=resultSet.getString("name");
                String sex=resultSet.getString("sex");
                System.out.println(id+name+age+sex);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            try {
                connect.close();
                statement.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }

        }


    }
}
